package com.itita.ww2.handler.requesthandler.worldmap;

import java.sql.SQLException;

import com.itita.ww2.core.MessageHandler;
import com.itita.ww2.core.WW2Exception;
import com.itita.ww2.enums.WW2ExceptionCode;
import com.itita.ww2.game.worldmap.WorldMapManager;
import com.itita.ww2.model.worldmap.Base;
import com.itita.ww2.utils.handler.IRequestOper;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;

/**
 * 获取某个据点的地图数据
 * @author NorthLan
 *
 */
public class GetBaseMap implements IRequestOper {

	@Override
	public boolean execute(String requestCMD, User user, ISFSObject params) throws WW2Exception, SQLException {
		int blockId = params.getInt("blockId");
		int cityId = params.getInt("cityId");
		int baseId = params.getInt("baseId");

		Base base = WorldMapManager.getInstance().getBase(blockId, cityId, baseId);
		if (base == null) {
			throw new WW2Exception(WW2ExceptionCode.WORLDMAP_BASE_NOT_FOUND);
		}

		MessageHandler.getInstance().sendMsg(requestCMD, base.getMap(), user, null, true);
		return true;
	}

}
